#include "Solution.h"
#include <iostream>

using namespace std;

int main()
{
	int n,m;
	Solution s;
	while(cin>>n)
	{
		if(n==0)
			break;
		cin>>m;
		int* A = new int[n];
		for(int i=0;i<n;i++)
			cin>>A[i];

		int k = s.removeElement(A,n,m);	
		for(int i=0;i<k;i++)
			cout<<A[i]<<" ";
		cout<<endl;
	}
}